Skip to content

[feat] '__eq__' method for SampleList#1053

Open
Shubham-Sahoo wants to merge 6 commits intofacebookresearch:mainfrom
Shubham-Sahoo:master
Open

[feat] '__eq__' method for SampleList#1053
Shubham-Sahoo wants to merge 6 commits intofacebookresearch:mainfrom
Shubham-Sahoo:master

Conversation

@Shubham-Sahoo
Copy link
Copy Markdown

@Shubham-Sahoo Shubham-Sahoo commented Aug 23, 2021

Added the eq method and tests for SampleList facebookresearch#454

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Aug 23, 2021
@Shubham-Sahoo Shubham-Sahoo changed the title __eq__ method for SampleList [feat] '__eq__' method for SampleList Aug 25, 2021
Copy link
Copy Markdown
Contributor

@apsdehal apsdehal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to MMF! Awesome first PR. I have left some comments. Address those and it should be good to land.

Comment thread mmf/common/sample.py Outdated
b = set(fields_other)

# Comparison between keys and early fail
if a==b:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter won't be happy with this.

Comment thread mmf/common/sample.py Outdated

# Compare Lists
else:
if not self[field]==other.get_field(field):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use either key access on both sides or use get_field on both sides.

Comment thread tests/common/test_sample.py Outdated
self.assertFalse(sample_list1 == sample_list3)
self.assertFalse(sample_list1 == sample_list4)
self.assertFalse(sample_list2 == sample_list4)
self.assertFalse(sample_list1 == sample_list5)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert more complex cases and cases which are not equal as well. Try testing SampleList inside SampleList or dict inside SampleList.

@Shubham-Sahoo
Copy link
Copy Markdown
Author

Shubham-Sahoo commented Aug 28, 2021

@apsdehal I have pushed the required changes, please have a look.

@Shubham-Sahoo Shubham-Sahoo requested a review from apsdehal August 28, 2021 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants